<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>鼠标事件</title>
</head>
<body>
<script>
    var div = document.createElement("div");
    div.style.height = "100px";
    div.style.width="100px";
    div.style.border="1px solid black";
    //鼠标按下事件
    div.onmousedown=function (){
        div.style.height="400px";
        div.style.width="400px";
    }
//鼠标移动到元素上事件
    div.onmouseenter=function (){
        //设备背景颜色为红色
        div.style.background="red";
    }
    //鼠标离开事件
    div.onmouseleave=function (){
        div.style.height="100px";
        div.style.width="100px";
        div.style.background=""
    }
    var body = document.getElementsByTagName("body")[0];
    body.appendChild(div)

</script>
</body>
</html>